!function (t, e) {
    "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : t.QrCodeWithLogo = e()
}(this, function () {
    "use strict";
    var t = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {};

    function e(t, e) {
        return t(e = {exports: {}}, e.exports), e.exports
    }

    var r = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (t) {
            return typeof t
        } : function (t) {
            return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t
        },
        n = "object" === ("undefined" == typeof self ? "undefined" : r(self)) && self.self === self && self || "object" === r(t) && t.global === t && t || t,
        o = function () {
            return "function" == typeof n.Promise && "function" == typeof n.Promise.prototype.then
        }, i = {}.toString, a = Array.isArray || function (t) {
            return "[object Array]" == i.call(t)
        };
    s.TYPED_ARRAY_SUPPORT = function () {
        try {
            var t = new Uint8Array(1);
            return t.__proto__ = {
                __proto__: Uint8Array.prototype, foo: function () {
                    return 42
                }
            }, 42 === t.foo()
        } catch (t) {
            return !1
        }
    }();
    var u = s.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;

    function s(t, e, r) {
        return s.TYPED_ARRAY_SUPPORT || this instanceof s ? "number" == typeof t ? l(this, t) : function (t, e, r, n) {
            if ("number" == typeof e) throw new TypeError('"value" argument must not be a number');
            if ("undefined" != typeof ArrayBuffer && e instanceof ArrayBuffer) return function (t, e, r, n) {
                if (r < 0 || e.byteLength < r) throw new RangeError("'offset' is out of bounds");
                if (e.byteLength < r + (n || 0)) throw new RangeError("'length' is out of bounds");
                var o;
                o = void 0 === r && void 0 === n ? new Uint8Array(e) : void 0 === n ? new Uint8Array(e, r) : new Uint8Array(e, r, n);
                s.TYPED_ARRAY_SUPPORT ? o.__proto__ = s.prototype : o = h(t, o);
                return o
            }(t, e, r, n);
            if ("string" == typeof e) return function (t, e) {
                var r = 0 | d(e), n = c(t, r), o = n.write(e);
                o !== r && (n = n.slice(0, o));
                return n
            }(t, e);
            return function (t, e) {
                if (s.isBuffer(e)) {
                    var r = 0 | f(e.length), n = c(t, r);
                    return 0 === n.length ? n : (e.copy(n, 0, 0, r), n)
                }
                if (e) {
                    if ("undefined" != typeof ArrayBuffer && e.buffer instanceof ArrayBuffer || "length" in e) return "number" != typeof e.length || (o = e.length) != o ? c(t, 0) : h(t, e);
                    if ("Buffer" === e.type && Array.isArray(e.data)) return h(t, e.data)
                }
                var o;
                throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")
            }(t, e)
        }(this, t, e, r) : new s(t, e, r)
    }

    function f(t) {
        if (t >= u) throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + u.toString(16) + " bytes");
        return 0 | t
    }

    function c(t, e) {
        var r;
        return s.TYPED_ARRAY_SUPPORT ? (r = new Uint8Array(e)).__proto__ = s.prototype : (null === (r = t) && (r = new s(e)), r.length = e), r
    }

    function l(t, e) {
        var r = c(t, e < 0 ? 0 : 0 | f(e));
        if (!s.TYPED_ARRAY_SUPPORT) for (var n = 0; n < e; ++n) r[n] = 0;
        return r
    }

    function h(t, e) {
        for (var r = e.length < 0 ? 0 : 0 | f(e.length), n = c(t, r), o = 0; o < r; o += 1) n[o] = 255 & e[o];
        return n
    }

    function g(t, e) {
        var r;
        e = e || 1 / 0;
        for (var n = t.length, o = null, i = [], a = 0; a < n; ++a) {
            if ((r = t.charCodeAt(a)) > 55295 && r < 57344) {
                if (!o) {
                    if (r > 56319) {
                        (e -= 3) > -1 && i.push(239, 191, 189);
                        continue
                    }
                    if (a + 1 === n) {
                        (e -= 3) > -1 && i.push(239, 191, 189);
                        continue
                    }
                    o = r;
                    continue
                }
                if (r < 56320) {
                    (e -= 3) > -1 && i.push(239, 191, 189), o = r;
                    continue
                }
                r = 65536 + (o - 55296 << 10 | r - 56320)
            } else o && (e -= 3) > -1 && i.push(239, 191, 189);
            if (o = null, r < 128) {
                if ((e -= 1) < 0) break;
                i.push(r)
            } else if (r < 2048) {
                if ((e -= 2) < 0) break;
                i.push(r >> 6 | 192, 63 & r | 128)
            } else if (r < 65536) {
                if ((e -= 3) < 0) break;
                i.push(r >> 12 | 224, r >> 6 & 63 | 128, 63 & r | 128)
            } else {
                if (!(r < 1114112)) throw new Error("Invalid code point");
                if ((e -= 4) < 0) break;
                i.push(r >> 18 | 240, r >> 12 & 63 | 128, r >> 6 & 63 | 128, 63 & r | 128)
            }
        }
        return i
    }

    function d(t) {
        return s.isBuffer(t) ? t.length : "undefined" != typeof ArrayBuffer && "function" == typeof ArrayBuffer.isView && (ArrayBuffer.isView(t) || t instanceof ArrayBuffer) ? t.byteLength : ("string" != typeof t && (t = "" + t), 0 === t.length ? 0 : g(t).length)
    }

    s.TYPED_ARRAY_SUPPORT && (s.prototype.__proto__ = Uint8Array.prototype, s.__proto__ = Uint8Array, "undefined" != typeof Symbol && Symbol.species && s[Symbol.species] === s && Object.defineProperty(s, Symbol.species, {
        value: null,
        configurable: !0,
        enumerable: !1,
        writable: !1
    })), s.prototype.write = function (t, e, r) {
        void 0 === e ? (r = this.length, e = 0) : void 0 === r && "string" == typeof e ? (r = this.length, e = 0) : isFinite(e) && (e |= 0, isFinite(r) ? r |= 0 : r = void 0);
        var n = this.length - e;
        if ((void 0 === r || r > n) && (r = n), t.length > 0 && (r < 0 || e < 0) || e > this.length) throw new RangeError("Attempt to write outside buffer bounds");
        return function (t, e, r, n) {
            return function (t, e, r, n) {
                for (var o = 0; o < n && !(o + r >= e.length || o >= t.length); ++o) e[o + r] = t[o];
                return o
            }(g(e, t.length - r), t, r, n)
        }(this, t, e, r)
    }, s.prototype.slice = function (t, e) {
        var r, n = this.length;
        if (t = ~~t, e = void 0 === e ? n : ~~e, t < 0 ? (t += n) < 0 && (t = 0) : t > n && (t = n), e < 0 ? (e += n) < 0 && (e = 0) : e > n && (e = n), e < t && (e = t), s.TYPED_ARRAY_SUPPORT) (r = this.subarray(t, e)).__proto__ = s.prototype; else {
            var o = e - t;
            r = new s(o, void 0);
            for (var i = 0; i < o; ++i) r[i] = this[i + t]
        }
        return r
    }, s.prototype.copy = function (t, e, r, n) {
        if (r || (r = 0), n || 0 === n || (n = this.length), e >= t.length && (e = t.length), e || (e = 0), n > 0 && n < r && (n = r), n === r) return 0;
        if (0 === t.length || 0 === this.length) return 0;
        if (e < 0) throw new RangeError("targetStart out of bounds");
        if (r < 0 || r >= this.length) throw new RangeError("sourceStart out of bounds");
        if (n < 0) throw new RangeError("sourceEnd out of bounds");
        n > this.length && (n = this.length), t.length - e < n - r && (n = t.length - e + r);
        var o, i = n - r;
        if (this === t && r < e && e < n) for (o = i - 1; o >= 0; --o) t[o + e] = this[o + r]; else if (i < 1e3 || !s.TYPED_ARRAY_SUPPORT) for (o = 0; o < i; ++o) t[o + e] = this[o + r]; else Uint8Array.prototype.set.call(t, this.subarray(r, r + i), e);
        return i
    }, s.prototype.fill = function (t, e, r) {
        if ("string" == typeof t) {
            if ("string" == typeof e ? (e = 0, r = this.length) : "string" == typeof r && (r = this.length), 1 === t.length) {
                var n = t.charCodeAt(0);
                n < 256 && (t = n)
            }
        } else "number" == typeof t && (t &= 255);
        if (e < 0 || this.length < e || this.length < r) throw new RangeError("Out of range index");
        if (r <= e) return this;
        var o;
        if (e >>>= 0, r = void 0 === r ? this.length : r >>> 0, t || (t = 0), "number" == typeof t) for (o = e; o < r; ++o) this[o] = t; else {
            var i = s.isBuffer(t) ? t : new s(t), a = i.length;
            for (o = 0; o < r - e; ++o) this[o + e] = i[o % a]
        }
        return this
    }, s.concat = function (t, e) {
        if (!a(t)) throw new TypeError('"list" argument must be an Array of Buffers');
        if (0 === t.length) return c(null, 0);
        var r;
        if (void 0 === e) for (e = 0, r = 0; r < t.length; ++r) e += t[r].length;
        var n = l(null, e), o = 0;
        for (r = 0; r < t.length; ++r) {
            var i = t[r];
            if (!s.isBuffer(i)) throw new TypeError('"list" argument must be an Array of Buffers');
            i.copy(n, o), o += i.length
        }
        return n
    }, s.byteLength = d, s.prototype._isBuffer = !0, s.isBuffer = function (t) {
        return !(null == t || !t._isBuffer)
    };
    var p, v = s,
        y = [0, 26, 44, 70, 100, 134, 172, 196, 242, 292, 346, 404, 466, 532, 581, 655, 733, 815, 901, 991, 1085, 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185, 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706],
        m = {
            getSymbolSize: function (t) {
                if (!t) throw new Error('"version" cannot be null or undefined');
                if (t < 1 || t > 40) throw new Error('"version" should be in range from 1 to 40');
                return 4 * t + 17
            }, getSymbolTotalCodewords: function (t) {
                return y[t]
            }, getBCHDigit: function (t) {
                for (var e = 0; 0 !== t;) e++, t >>>= 1;
                return e
            }, setToSJISFunction: function (t) {
                if ("function" != typeof t) throw new Error('"toSJISFunc" is not a valid function.');
                p = t
            }, isKanjiModeEnabled: function () {
                return void 0 !== p
            }, toSJIS: function (t) {
                return p(t)
            }
        }, w = e(function (t, e) {
            e.L = {bit: 1}, e.M = {bit: 0}, e.Q = {bit: 3}, e.H = {bit: 2}, e.isValid = function (t) {
                return t && void 0 !== t.bit && t.bit >= 0 && t.bit < 4
            }, e.from = function (t, r) {
                if (e.isValid(t)) return t;
                try {
                    return function (t) {
                        if ("string" != typeof t) throw new Error("Param is not a string");
                        switch (t.toLowerCase()) {
                            case"l":
                            case"low":
                                return e.L;
                            case"m":
                            case"medium":
                                return e.M;
                            case"q":
                            case"quartile":
                                return e.Q;
                            case"h":
                            case"high":
                                return e.H;
                            default:
                                throw new Error("Unknown EC Level: " + t)
                        }
                    }(t)
                } catch (t) {
                    return r
                }
            }
        });
    w.L, w.M, w.Q, w.H, w.isValid, w.from;

    function E() {
        this.buffer = [], this.length = 0
    }

    E.prototype = {
        get: function (t) {
            var e = Math.floor(t / 8);
            return 1 == (this.buffer[e] >>> 7 - t % 8 & 1)
        }, put: function (t, e) {
            for (var r = 0; r < e; r++) this.putBit(1 == (t >>> e - r - 1 & 1))
        }, getLengthInBits: function () {
            return this.length
        }, putBit: function (t) {
            var e = Math.floor(this.length / 8);
            this.buffer.length <= e && this.buffer.push(0), t && (this.buffer[e] |= 128 >>> this.length % 8), this.length++
        }
    };
    var A = E;

    function b(t) {
        if (!t || t < 1) throw new Error("BitMatrix size must be defined and greater than 0");
        this.size = t, this.data = new v(t * t), this.data.fill(0), this.reservedBit = new v(t * t), this.reservedBit.fill(0)
    }

    b.prototype.set = function (t, e, r, n) {
        var o = t * this.size + e;
        this.data[o] = r, n && (this.reservedBit[o] = !0)
    }, b.prototype.get = function (t, e) {
        return this.data[t * this.size + e]
    }, b.prototype.xor = function (t, e, r) {
        this.data[t * this.size + e] ^= r
    }, b.prototype.isReserved = function (t, e) {
        return this.reservedBit[t * this.size + e]
    };
    var B = b, P = e(function (t, e) {
            var r = m.getSymbolSize;
            e.getRowColCoords = function (t) {
                if (1 === t) return [];
                for (var e = Math.floor(t / 7) + 2, n = r(t), o = 145 === n ? 26 : 2 * Math.ceil((n - 13) / (2 * e - 2)), i = [n - 7], a = 1; a < e - 1; a++) i[a] = i[a - 1] - o;
                return i.push(6), i.reverse()
            }, e.getPositions = function (t) {
                for (var r = [], n = e.getRowColCoords(t), o = n.length, i = 0; i < o; i++) for (var a = 0; a < o; a++) 0 === i && 0 === a || 0 === i && a === o - 1 || i === o - 1 && 0 === a || r.push([n[i], n[a]]);
                return r
            }
        }), C = (P.getRowColCoords, P.getPositions, m.getSymbolSize), R = {
            getPositions: function (t) {
                var e = C(t);
                return [[0, 0], [e - 7, 0], [0, e - 7]]
            }
        }, T = e(function (t, e) {
            e.Patterns = {
                PATTERN000: 0,
                PATTERN001: 1,
                PATTERN010: 2,
                PATTERN011: 3,
                PATTERN100: 4,
                PATTERN101: 5,
                PATTERN110: 6,
                PATTERN111: 7
            };
            var r = 3, n = 3, o = 40, i = 10;

            function a(t, r, n) {
                switch (t) {
                    case e.Patterns.PATTERN000:
                        return (r + n) % 2 == 0;
                    case e.Patterns.PATTERN001:
                        return r % 2 == 0;
                    case e.Patterns.PATTERN010:
                        return n % 3 == 0;
                    case e.Patterns.PATTERN011:
                        return (r + n) % 3 == 0;
                    case e.Patterns.PATTERN100:
                        return (Math.floor(r / 2) + Math.floor(n / 3)) % 2 == 0;
                    case e.Patterns.PATTERN101:
                        return r * n % 2 + r * n % 3 == 0;
                    case e.Patterns.PATTERN110:
                        return (r * n % 2 + r * n % 3) % 2 == 0;
                    case e.Patterns.PATTERN111:
                        return (r * n % 3 + (r + n) % 2) % 2 == 0;
                    default:
                        throw new Error("bad maskPattern:" + t)
                }
            }

            e.isValid = function (t) {
                return t && "" !== t && !isNaN(t) && t >= 0 && t <= 7
            }, e.from = function (t) {
                return e.isValid(t) ? parseInt(t, 10) : void 0
            }, e.getPenaltyN1 = function (t) {
                for (var e = t.size, n = 0, o = 0, i = 0, a = null, u = null, s = 0; s < e; s++) {
                    o = i = 0, a = u = null;
                    for (var f = 0; f < e; f++) {
                        var c = t.get(s, f);
                        c === a ? o++ : (o >= 5 && (n += r + (o - 5)), a = c, o = 1), (c = t.get(f, s)) === u ? i++ : (i >= 5 && (n += r + (i - 5)), u = c, i = 1)
                    }
                    o >= 5 && (n += r + (o - 5)), i >= 5 && (n += r + (i - 5))
                }
                return n
            }, e.getPenaltyN2 = function (t) {
                for (var e = t.size, r = 0, o = 0; o < e - 1; o++) for (var i = 0; i < e - 1; i++) {
                    var a = t.get(o, i) + t.get(o, i + 1) + t.get(o + 1, i) + t.get(o + 1, i + 1);
                    4 !== a && 0 !== a || r++
                }
                return r * n
            }, e.getPenaltyN3 = function (t) {
                for (var e = t.size, r = 0, n = 0, i = 0, a = 0; a < e; a++) {
                    n = i = 0;
                    for (var u = 0; u < e; u++) n = n << 1 & 2047 | t.get(a, u), u >= 10 && (1488 === n || 93 === n) && r++, i = i << 1 & 2047 | t.get(u, a), u >= 10 && (1488 === i || 93 === i) && r++
                }
                return r * o
            }, e.getPenaltyN4 = function (t) {
                for (var e = 0, r = t.data.length, n = 0; n < r; n++) e += t.data[n];
                return Math.abs(Math.ceil(100 * e / r / 5) - 10) * i
            }, e.applyMask = function (t, e) {
                for (var r = e.size, n = 0; n < r; n++) for (var o = 0; o < r; o++) e.isReserved(o, n) || e.xor(o, n, a(t, o, n))
            }, e.getBestMask = function (t, r) {
                for (var n = Object.keys(e.Patterns).length, o = 0, i = 1 / 0, a = 0; a < n; a++) {
                    r(a), e.applyMask(a, t);
                    var u = e.getPenaltyN1(t) + e.getPenaltyN2(t) + e.getPenaltyN3(t) + e.getPenaltyN4(t);
                    e.applyMask(a, t), u < i && (i = u, o = a)
                }
                return o
            }
        }),
        I = (T.Patterns, T.isValid, T.from, T.getPenaltyN1, T.getPenaltyN2, T.getPenaltyN3, T.getPenaltyN4, T.applyMask, T.getBestMask, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 4, 1, 2, 4, 4, 2, 4, 4, 4, 2, 4, 6, 5, 2, 4, 6, 6, 2, 5, 8, 8, 4, 5, 8, 8, 4, 5, 8, 11, 4, 8, 10, 11, 4, 9, 12, 16, 4, 9, 16, 16, 6, 10, 12, 18, 6, 10, 17, 16, 6, 11, 16, 19, 6, 13, 18, 21, 7, 14, 21, 25, 8, 16, 20, 25, 8, 17, 23, 25, 9, 17, 23, 34, 9, 18, 25, 30, 10, 20, 27, 32, 12, 21, 29, 35, 12, 23, 34, 37, 12, 25, 34, 40, 13, 26, 35, 42, 14, 28, 38, 45, 15, 29, 40, 48, 16, 31, 43, 51, 17, 33, 45, 54, 18, 35, 48, 57, 19, 37, 51, 60, 19, 38, 53, 63, 20, 40, 56, 66, 21, 43, 59, 70, 22, 45, 62, 74, 24, 47, 65, 77, 25, 49, 68, 81]),
        M = [7, 10, 13, 17, 10, 16, 22, 28, 15, 26, 36, 44, 20, 36, 52, 64, 26, 48, 72, 88, 36, 64, 96, 112, 40, 72, 108, 130, 48, 88, 132, 156, 60, 110, 160, 192, 72, 130, 192, 224, 80, 150, 224, 264, 96, 176, 260, 308, 104, 198, 288, 352, 120, 216, 320, 384, 132, 240, 360, 432, 144, 280, 408, 480, 168, 308, 448, 532, 180, 338, 504, 588, 196, 364, 546, 650, 224, 416, 600, 700, 224, 442, 644, 750, 252, 476, 690, 816, 270, 504, 750, 900, 300, 560, 810, 960, 312, 588, 870, 1050, 336, 644, 952, 1110, 360, 700, 1020, 1200, 390, 728, 1050, 1260, 420, 784, 1140, 1350, 450, 812, 1200, 1440, 480, 868, 1290, 1530, 510, 924, 1350, 1620, 540, 980, 1440, 1710, 570, 1036, 1530, 1800, 570, 1064, 1590, 1890, 600, 1120, 1680, 1980, 630, 1204, 1770, 2100, 660, 1260, 1860, 2220, 720, 1316, 1950, 2310, 750, 1372, 2040, 2430],
        N = {
            getBlocksCount: function (t, e) {
                switch (e) {
                    case w.L:
                        return I[4 * (t - 1) + 0];
                    case w.M:
                        return I[4 * (t - 1) + 1];
                    case w.Q:
                        return I[4 * (t - 1) + 2];
                    case w.H:
                        return I[4 * (t - 1) + 3];
                    default:
                        return
                }
            }, getTotalCodewordsCount: function (t, e) {
                switch (e) {
                    case w.L:
                        return M[4 * (t - 1) + 0];
                    case w.M:
                        return M[4 * (t - 1) + 1];
                    case w.Q:
                        return M[4 * (t - 1) + 2];
                    case w.H:
                        return M[4 * (t - 1) + 3];
                    default:
                        return
                }
            }
        }, S = new v(512), _ = new v(256);
    !function () {
        for (var t = 1, e = 0; e < 255; e++) S[e] = t, _[t] = e, 256 & (t <<= 1) && (t ^= 285);
        for (e = 255; e < 512; e++) S[e] = S[e - 255]
    }();
    var L = function (t) {
        return S[t]
    }, U = function (t, e) {
        return 0 === t || 0 === e ? 0 : S[_[t] + _[e]]
    }, x = e(function (t, e) {
        e.mul = function (t, e) {
            var r = new v(t.length + e.length - 1);
            r.fill(0);
            for (var n = 0; n < t.length; n++) for (var o = 0; o < e.length; o++) r[n + o] ^= U(t[n], e[o]);
            return r
        }, e.mod = function (t, e) {
            for (var r = new v(t); r.length - e.length >= 0;) {
                for (var n = r[0], o = 0; o < e.length; o++) r[o] ^= U(e[o], n);
                for (var i = 0; i < r.length && 0 === r[i];) i++;
                r = r.slice(i)
            }
            return r
        }, e.generateECPolynomial = function (t) {
            for (var r = new v([1]), n = 0; n < t; n++) r = e.mul(r, [1, L(n)]);
            return r
        }
    });
    x.mul, x.mod, x.generateECPolynomial;

    function Y(t) {
        this.genPoly = void 0, this.degree = t, this.degree && this.initialize(this.degree)
    }

    Y.prototype.initialize = function (t) {
        this.degree = t, this.genPoly = x.generateECPolynomial(this.degree)
    }, Y.prototype.encode = function (t) {
        if (!this.genPoly) throw new Error("Encoder not initialized");
        var e = new v(this.degree);
        e.fill(0);
        var r = v.concat([t, e], t.length + this.degree), n = x.mod(r, this.genPoly), o = this.degree - n.length;
        if (o > 0) {
            var i = new v(this.degree);
            return i.fill(0), n.copy(i, o), i
        }
        return n
    };
    var D = Y,
        k = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+",
        F = "(?:(?![A-Z0-9 $%*+\\-./:]|" + (k = k.replace(/u/g, "\\u")) + ").)+", z = new RegExp(k, "g"),
        O = new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g"), H = new RegExp(F, "g"), J = new RegExp("[0-9]+", "g"),
        K = new RegExp("[A-Z $%*+\\-./:]+", "g"), V = new RegExp("^" + k + "$"), j = new RegExp("^[0-9]+$"),
        Q = new RegExp("^[A-Z0-9 $%*+\\-./:]+$"), q = {
            KANJI: z, BYTE_KANJI: O, BYTE: H, NUMERIC: J, ALPHANUMERIC: K, testKanji: function (t) {
                return V.test(t)
            }, testNumeric: function (t) {
                return j.test(t)
            }, testAlphanumeric: function (t) {
                return Q.test(t)
            }
        }, $ = e(function (t, e) {
            e.NUMERIC = {id: "Numeric", bit: 1, ccBits: [10, 12, 14]}, e.ALPHANUMERIC = {
                id: "Alphanumeric",
                bit: 2,
                ccBits: [9, 11, 13]
            }, e.BYTE = {id: "Byte", bit: 4, ccBits: [8, 16, 16]}, e.KANJI = {
                id: "Kanji",
                bit: 8,
                ccBits: [8, 10, 12]
            }, e.MIXED = {bit: -1}, e.getCharCountIndicator = function (t, e) {
                if (!t.ccBits) throw new Error("Invalid mode: " + t);
                if (!W.isValid(e)) throw new Error("Invalid version: " + e);
                return e >= 1 && e < 10 ? t.ccBits[0] : e < 27 ? t.ccBits[1] : t.ccBits[2]
            }, e.getBestModeForData = function (t) {
                return q.testNumeric(t) ? e.NUMERIC : q.testAlphanumeric(t) ? e.ALPHANUMERIC : q.testKanji(t) ? e.KANJI : e.BYTE
            }, e.toString = function (t) {
                if (t && t.id) return t.id;
                throw new Error("Invalid mode")
            }, e.isValid = function (t) {
                return t && t.bit && t.ccBits
            }, e.from = function (t, r) {
                if (e.isValid(t)) return t;
                try {
                    return function (t) {
                        if ("string" != typeof t) throw new Error("Param is not a string");
                        switch (t.toLowerCase()) {
                            case"numeric":
                                return e.NUMERIC;
                            case"alphanumeric":
                                return e.ALPHANUMERIC;
                            case"kanji":
                                return e.KANJI;
                            case"byte":
                                return e.BYTE;
                            default:
                                throw new Error("Unknown mode: " + t)
                        }
                    }(t)
                } catch (t) {
                    return r
                }
            }
        }),
        W = ($.NUMERIC, $.ALPHANUMERIC, $.BYTE, $.KANJI, $.MIXED, $.getCharCountIndicator, $.getBestModeForData, $.isValid, $.from, e(function (t, e) {
            var r = m.getBCHDigit(7973);

            function n(t, e) {
                return $.getCharCountIndicator(t, e) + 4
            }

            function o(t, e) {
                var r = 0;
                return t.forEach(function (t) {
                    var o = n(t.mode, e);
                    r += o + t.getBitsLength()
                }), r
            }

            e.isValid = function (t) {
                return !isNaN(t) && t >= 1 && t <= 40
            }, e.from = function (t, r) {
                return e.isValid(t) ? parseInt(t, 10) : r
            }, e.getCapacity = function (t, r, o) {
                if (!e.isValid(t)) throw new Error("Invalid QR Code version");
                void 0 === o && (o = $.BYTE);
                var i = 8 * (m.getSymbolTotalCodewords(t) - N.getTotalCodewordsCount(t, r));
                if (o === $.MIXED) return i;
                var a = i - n(o, t);
                switch (o) {
                    case $.NUMERIC:
                        return Math.floor(a / 10 * 3);
                    case $.ALPHANUMERIC:
                        return Math.floor(a / 11 * 2);
                    case $.KANJI:
                        return Math.floor(a / 13);
                    case $.BYTE:
                    default:
                        return Math.floor(a / 8)
                }
            }, e.getBestVersionForData = function (t, r) {
                var n, i = w.from(r, w.M);
                if (a(t)) {
                    if (t.length > 1) return function (t, r) {
                        for (var n = 1; n <= 40; n++) if (o(t, n) <= e.getCapacity(n, r, $.MIXED)) return n
                    }(t, i);
                    if (0 === t.length) return 1;
                    n = t[0]
                } else n = t;
                return function (t, r, n) {
                    for (var o = 1; o <= 40; o++) if (r <= e.getCapacity(o, n, t)) return o
                }(n.mode, n.getLength(), i)
            }, e.getEncodedBits = function (t) {
                if (!e.isValid(t) || t < 7) throw new Error("Invalid QR Code version");
                for (var n = t << 12; m.getBCHDigit(n) - r >= 0;) n ^= 7973 << m.getBCHDigit(n) - r;
                return t << 12 | n
            }
        })), X = (W.isValid, W.from, W.getCapacity, W.getBestVersionForData, W.getEncodedBits, m.getBCHDigit(1335)),
        Z = {
            getEncodedBits: function (t, e) {
                for (var r = t.bit << 3 | e, n = r << 10; m.getBCHDigit(n) - X >= 0;) n ^= 1335 << m.getBCHDigit(n) - X;
                return 21522 ^ (r << 10 | n)
            }
        };

    function G(t) {
        this.mode = $.NUMERIC, this.data = t.toString()
    }

    G.getBitsLength = function (t) {
        return 10 * Math.floor(t / 3) + (t % 3 ? t % 3 * 3 + 1 : 0)
    }, G.prototype.getLength = function () {
        return this.data.length
    }, G.prototype.getBitsLength = function () {
        return G.getBitsLength(this.data.length)
    }, G.prototype.write = function (t) {
        var e, r, n;
        for (e = 0; e + 3 <= this.data.length; e += 3) r = this.data.substr(e, 3), n = parseInt(r, 10), t.put(n, 10);
        var o = this.data.length - e;
        o > 0 && (r = this.data.substr(e), n = parseInt(r, 10), t.put(n, 3 * o + 1))
    };
    var tt = G,
        et = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", " ", "$", "%", "*", "+", "-", ".", "/", ":"];

    function rt(t) {
        this.mode = $.ALPHANUMERIC, this.data = t
    }

    rt.getBitsLength = function (t) {
        return 11 * Math.floor(t / 2) + t % 2 * 6
    }, rt.prototype.getLength = function () {
        return this.data.length
    }, rt.prototype.getBitsLength = function () {
        return rt.getBitsLength(this.data.length)
    }, rt.prototype.write = function (t) {
        var e;
        for (e = 0; e + 2 <= this.data.length; e += 2) {
            var r = 45 * et.indexOf(this.data[e]);
            r += et.indexOf(this.data[e + 1]), t.put(r, 11)
        }
        this.data.length % 2 && t.put(et.indexOf(this.data[e]), 6)
    };
    var nt = rt;

    function ot(t) {
        this.mode = $.BYTE, this.data = new v(t)
    }

    ot.getBitsLength = function (t) {
        return 8 * t
    }, ot.prototype.getLength = function () {
        return this.data.length
    }, ot.prototype.getBitsLength = function () {
        return ot.getBitsLength(this.data.length)
    }, ot.prototype.write = function (t) {
        for (var e = 0, r = this.data.length; e < r; e++) t.put(this.data[e], 8)
    };
    var it = ot;

    function at(t) {
        this.mode = $.KANJI, this.data = t
    }

    at.getBitsLength = function (t) {
        return 13 * t
    }, at.prototype.getLength = function () {
        return this.data.length
    }, at.prototype.getBitsLength = function () {
        return at.getBitsLength(this.data.length)
    }, at.prototype.write = function (t) {
        var e;
        for (e = 0; e < this.data.length; e++) {
            var r = m.toSJIS(this.data[e]);
            if (r >= 33088 && r <= 40956) r -= 33088; else {
                if (!(r >= 57408 && r <= 60351)) throw new Error("Invalid SJIS character: " + this.data[e] + "\nMake sure your charset is UTF-8");
                r -= 49472
            }
            r = 192 * (r >>> 8 & 255) + (255 & r), t.put(r, 13)
        }
    };
    var ut = at, st = e(function (t) {
        var e = {
            single_source_shortest_paths: function (t, r, n) {
                var o = {}, i = {};
                i[r] = 0;
                var a, u, s, f, c, l, h, g = e.PriorityQueue.make();
                for (g.push(r, 0); !g.empty();) for (s in u = (a = g.pop()).value, f = a.cost, c = t[u] || {}) c.hasOwnProperty(s) && (l = f + c[s], h = i[s], (void 0 === i[s] || h > l) && (i[s] = l, g.push(s, l), o[s] = u));
                if (void 0 !== n && void 0 === i[n]) {
                    var d = ["Could not find a path from ", r, " to ", n, "."].join("");
                    throw new Error(d)
                }
                return o
            }, extract_shortest_path_from_predecessor_list: function (t, e) {
                for (var r = [], n = e; n;) r.push(n), t[n], n = t[n];
                return r.reverse(), r
            }, find_path: function (t, r, n) {
                var o = e.single_source_shortest_paths(t, r, n);
                return e.extract_shortest_path_from_predecessor_list(o, n)
            }, PriorityQueue: {
                make: function (t) {
                    var r, n = e.PriorityQueue, o = {};
                    for (r in t = t || {}, n) n.hasOwnProperty(r) && (o[r] = n[r]);
                    return o.queue = [], o.sorter = t.sorter || n.default_sorter, o
                }, default_sorter: function (t, e) {
                    return t.cost - e.cost
                }, push: function (t, e) {
                    var r = {value: t, cost: e};
                    this.queue.push(r), this.queue.sort(this.sorter)
                }, pop: function () {
                    return this.queue.shift()
                }, empty: function () {
                    return 0 === this.queue.length
                }
            }
        };
        t.exports = e
    }), ft = e(function (t, e) {
        function r(t) {
            return unescape(encodeURIComponent(t)).length
        }

        function n(t, e, r) {
            for (var n, o = []; null !== (n = t.exec(r));) o.push({
                data: n[0],
                index: n.index,
                mode: e,
                length: n[0].length
            });
            return o
        }

        function o(t) {
            var e, r, o = n(q.NUMERIC, $.NUMERIC, t), i = n(q.ALPHANUMERIC, $.ALPHANUMERIC, t);
            return m.isKanjiModeEnabled() ? (e = n(q.BYTE, $.BYTE, t), r = n(q.KANJI, $.KANJI, t)) : (e = n(q.BYTE_KANJI, $.BYTE, t), r = []), o.concat(i, e, r).sort(function (t, e) {
                return t.index - e.index
            }).map(function (t) {
                return {data: t.data, mode: t.mode, length: t.length}
            })
        }

        function i(t, e) {
            switch (e) {
                case $.NUMERIC:
                    return tt.getBitsLength(t);
                case $.ALPHANUMERIC:
                    return nt.getBitsLength(t);
                case $.KANJI:
                    return ut.getBitsLength(t);
                case $.BYTE:
                    return it.getBitsLength(t)
            }
        }

        function a(t, e) {
            var r, n = $.getBestModeForData(t);
            if ((r = $.from(e, n)) !== $.BYTE && r.bit < n.bit) throw new Error('"' + t + '" cannot be encoded with mode ' + $.toString(r) + ".\n Suggested mode is: " + $.toString(n));
            switch (r !== $.KANJI || m.isKanjiModeEnabled() || (r = $.BYTE), r) {
                case $.NUMERIC:
                    return new tt(t);
                case $.ALPHANUMERIC:
                    return new nt(t);
                case $.KANJI:
                    return new ut(t);
                case $.BYTE:
                    return new it(t)
            }
        }

        e.fromArray = function (t) {
            return t.reduce(function (t, e) {
                return "string" == typeof e ? t.push(a(e, null)) : e.data && t.push(a(e.data, e.mode)), t
            }, [])
        }, e.fromString = function (t, n) {
            for (var a = function (t, e) {
                for (var r = {}, n = {start: {}}, o = ["start"], a = 0; a < t.length; a++) {
                    for (var u = t[a], s = [], f = 0; f < u.length; f++) {
                        var c = u[f], l = "" + a + f;
                        s.push(l), r[l] = {node: c, lastCount: 0}, n[l] = {};
                        for (var h = 0; h < o.length; h++) {
                            var g = o[h];
                            r[g] && r[g].node.mode === c.mode ? (n[g][l] = i(r[g].lastCount + c.length, c.mode) - i(r[g].lastCount, c.mode), r[g].lastCount += c.length) : (r[g] && (r[g].lastCount = c.length), n[g][l] = i(c.length, c.mode) + 4 + $.getCharCountIndicator(c.mode, e))
                        }
                    }
                    o = s
                }
                for (h = 0; h < o.length; h++) n[o[h]].end = 0;
                return {map: n, table: r}
            }(function (t) {
                for (var e = [], n = 0; n < t.length; n++) {
                    var o = t[n];
                    switch (o.mode) {
                        case $.NUMERIC:
                            e.push([o, {data: o.data, mode: $.ALPHANUMERIC, length: o.length}, {
                                data: o.data,
                                mode: $.BYTE,
                                length: o.length
                            }]);
                            break;
                        case $.ALPHANUMERIC:
                            e.push([o, {data: o.data, mode: $.BYTE, length: o.length}]);
                            break;
                        case $.KANJI:
                            e.push([o, {data: o.data, mode: $.BYTE, length: r(o.data)}]);
                            break;
                        case $.BYTE:
                            e.push([{data: o.data, mode: $.BYTE, length: r(o.data)}])
                    }
                }
                return e
            }(o(t, m.isKanjiModeEnabled())), n), u = st.find_path(a.map, "start", "end"), s = [], f = 1; f < u.length - 1; f++) s.push(a.table[u[f]].node);
            return e.fromArray(function (t) {
                return t.reduce(function (t, e) {
                    var r = t.length - 1 >= 0 ? t[t.length - 1] : null;
                    return r && r.mode === e.mode ? (t[t.length - 1].data += e.data, t) : (t.push(e), t)
                }, [])
            }(s))
        }, e.rawSplit = function (t) {
            return e.fromArray(o(t, m.isKanjiModeEnabled()))
        }
    });
    ft.fromArray, ft.fromString, ft.rawSplit;

    function ct(t, e, r) {
        var n, o, i = t.size, a = Z.getEncodedBits(e, r);
        for (n = 0; n < 15; n++) o = 1 == (a >> n & 1), n < 6 ? t.set(n, 8, o, !0) : n < 8 ? t.set(n + 1, 8, o, !0) : t.set(i - 15 + n, 8, o, !0), n < 8 ? t.set(8, i - n - 1, o, !0) : n < 9 ? t.set(8, 15 - n - 1 + 1, o, !0) : t.set(8, 15 - n - 1, o, !0);
        t.set(i - 8, 8, 1, !0)
    }

    function lt(t, e, r) {
        var n = new A;
        r.forEach(function (e) {
            n.put(e.mode.bit, 4), n.put(e.getLength(), $.getCharCountIndicator(e.mode, t)), e.write(n)
        });
        var o = 8 * (m.getSymbolTotalCodewords(t) - N.getTotalCodewordsCount(t, e));
        for (n.getLengthInBits() + 4 <= o && n.put(0, 4); n.getLengthInBits() % 8 != 0;) n.putBit(0);
        for (var i = (o - n.getLengthInBits()) / 8, a = 0; a < i; a++) n.put(a % 2 ? 17 : 236, 8);
        return function (t, e, r) {
            for (var n = m.getSymbolTotalCodewords(e), o = N.getTotalCodewordsCount(e, r), i = n - o, a = N.getBlocksCount(e, r), u = a - n % a, s = Math.floor(n / a), f = Math.floor(i / a), c = f + 1, l = s - f, h = new D(l), g = 0, d = new Array(a), p = new Array(a), y = 0, w = new v(t.buffer), E = 0; E < a; E++) {
                var A = E < u ? f : c;
                d[E] = w.slice(g, g + A), p[E] = h.encode(d[E]), g += A, y = Math.max(y, A)
            }
            var b, B, P = new v(n), C = 0;
            for (b = 0; b < y; b++) for (B = 0; B < a; B++) b < d[B].length && (P[C++] = d[B][b]);
            for (b = 0; b < l; b++) for (B = 0; B < a; B++) P[C++] = p[B][b];
            return P
        }(n, t, e)
    }

    function ht(t, e, r, n) {
        var o;
        if (a(t)) o = ft.fromArray(t); else {
            if ("string" != typeof t) throw new Error("Invalid data");
            var i = e;
            if (!i) {
                var u = ft.rawSplit(t);
                i = W.getBestVersionForData(u, r)
            }
            o = ft.fromString(t, i || 40)
        }
        var s = W.getBestVersionForData(o, r);
        if (!s) throw new Error("The amount of data is too big to be stored in a QR Code");
        if (e) {
            if (e < s) throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: " + s + ".\n")
        } else e = s;
        var f = lt(e, r, o), c = m.getSymbolSize(e), l = new B(c);
        return function (t, e) {
            for (var r = t.size, n = R.getPositions(e), o = 0; o < n.length; o++) for (var i = n[o][0], a = n[o][1], u = -1; u <= 7; u++) if (!(i + u <= -1 || r <= i + u)) for (var s = -1; s <= 7; s++) a + s <= -1 || r <= a + s || (u >= 0 && u <= 6 && (0 === s || 6 === s) || s >= 0 && s <= 6 && (0 === u || 6 === u) || u >= 2 && u <= 4 && s >= 2 && s <= 4 ? t.set(i + u, a + s, !0, !0) : t.set(i + u, a + s, !1, !0))
        }(l, e), function (t) {
            for (var e = t.size, r = 8; r < e - 8; r++) {
                var n = r % 2 == 0;
                t.set(r, 6, n, !0), t.set(6, r, n, !0)
            }
        }(l), function (t, e) {
            for (var r = P.getPositions(e), n = 0; n < r.length; n++) for (var o = r[n][0], i = r[n][1], a = -2; a <= 2; a++) for (var u = -2; u <= 2; u++) -2 === a || 2 === a || -2 === u || 2 === u || 0 === a && 0 === u ? t.set(o + a, i + u, !0, !0) : t.set(o + a, i + u, !1, !0)
        }(l, e), ct(l, r, 0), e >= 7 && function (t, e) {
            for (var r, n, o, i = t.size, a = W.getEncodedBits(e), u = 0; u < 18; u++) r = Math.floor(u / 3), n = u % 3 + i - 8 - 3, o = 1 == (a >> u & 1), t.set(r, n, o, !0), t.set(n, r, o, !0)
        }(l, e), function (t, e) {
            for (var r = t.size, n = -1, o = r - 1, i = 7, a = 0, u = r - 1; u > 0; u -= 2) for (6 === u && u--; ;) {
                for (var s = 0; s < 2; s++) if (!t.isReserved(o, u - s)) {
                    var f = !1;
                    a < e.length && (f = 1 == (e[a] >>> i & 1)), t.set(o, u - s, f), -1 == --i && (a++, i = 7)
                }
                if ((o += n) < 0 || r <= o) {
                    o -= n, n = -n;
                    break
                }
            }
        }(l, f), n || (n = T.getBestMask(l, ct.bind(null, l, r))), T.applyMask(n, l), ct(l, r, n), {
            modules: l,
            version: e,
            errorCorrectionLevel: r,
            maskPattern: n,
            segments: o
        }
    }

    var gt = {
        create: function (t, e) {
            if (void 0 === t || "" === t) throw new Error("No input text");
            var r, n, o = w.M;
            return void 0 !== e && (o = w.from(e.errorCorrectionLevel, w.M), r = W.from(e.version), n = T.from(e.maskPattern), e.toSJISFunc && m.setToSJISFunction(e.toSJISFunc)), ht(t, r, o, n)
        }
    }, dt = e(function (t, e) {
        function r(t) {
            if ("string" != typeof t) throw new Error("Color should be defined as hex string");
            var e = t.slice().replace("#", "").split("");
            if (e.length < 3 || 5 === e.length || e.length > 8) throw new Error("Invalid hex color: " + t);
            3 !== e.length && 4 !== e.length || (e = Array.prototype.concat.apply([], e.map(function (t) {
                return [t, t]
            }))), 6 === e.length && e.push("F", "F");
            var r = parseInt(e.join(""), 16);
            return {r: r >> 24 & 255, g: r >> 16 & 255, b: r >> 8 & 255, a: 255 & r, hex: "#" + e.slice(0, 6).join("")}
        }

        e.getOptions = function (t) {
            t || (t = {}), t.color || (t.color = {});
            var e = void 0 === t.margin || null === t.margin || t.margin < 0 ? 4 : t.margin,
                n = t.width && t.width >= 21 ? t.width : void 0, o = t.scale || 4;
            return {
                width: n,
                scale: n ? 4 : o,
                margin: e,
                color: {dark: r(t.color.dark || "#000000ff"), light: r(t.color.light || "#ffffffff")},
                type: t.type,
                rendererOpts: t.rendererOpts || {}
            }
        }, e.getScale = function (t, e) {
            return e.width && e.width >= t + 2 * e.margin ? e.width / (t + 2 * e.margin) : e.scale
        }, e.getImageWidth = function (t, r) {
            var n = e.getScale(t, r);
            return Math.floor((t + 2 * r.margin) * n)
        }, e.qrToImageData = function (t, r, n) {
            for (var o = r.modules.size, i = r.modules.data, a = e.getScale(o, n), u = Math.floor((o + 2 * n.margin) * a), s = n.margin * a, f = [n.color.light, n.color.dark], c = 0; c < u; c++) for (var l = 0; l < u; l++) {
                var h = 4 * (c * u + l), g = n.color.light;
                if (c >= s && l >= s && c < u - s && l < u - s) g = f[i[Math.floor((c - s) / a) * o + Math.floor((l - s) / a)] ? 1 : 0];
                t[h++] = g.r, t[h++] = g.g, t[h++] = g.b, t[h] = g.a
            }
        }
    }), pt = (dt.getOptions, dt.getScale, dt.getImageWidth, dt.qrToImageData, e(function (t, e) {
        e.render = function (t, e, r) {
            var n = r, o = e;
            void 0 !== n || e && e.getContext || (n = e, e = void 0), e || (o = function () {
                try {
                    return document.createElement("canvas")
                } catch (t) {
                    throw new Error("You need to specify a canvas element")
                }
            }()), n = dt.getOptions(n);
            var i = dt.getImageWidth(t.modules.size, n), a = o.getContext("2d"), u = a.createImageData(i, i);
            return dt.qrToImageData(u.data, t, n), function (t, e, r) {
                t.clearRect(0, 0, e.width, e.height), e.style || (e.style = {}), e.height = r, e.width = r, e.style.height = r + "px", e.style.width = r + "px"
            }(a, o, i), a.putImageData(u, 0, 0), o
        }, e.renderToDataURL = function (t, r, n) {
            var o = n;
            void 0 !== o || r && r.getContext || (o = r, r = void 0), o || (o = {});
            var i = e.render(t, r, o), a = o.type || "image/png", u = o.rendererOpts || {};
            return i.toDataURL(a, u.quality)
        }
    }));
    pt.render, pt.renderToDataURL;

    function vt(t, e) {
        var r = t.a / 255, n = e + '="' + t.hex + '"';
        return r < 1 ? n + " " + e + '-opacity="' + r.toFixed(2).slice(1) + '"' : n
    }

    function yt(t, e, r) {
        var n = t + e;
        return void 0 !== r && (n += " " + r), n
    }

    var mt = function (t, e, r) {
        var n = dt.getOptions(e), o = t.modules.size, i = t.modules.data, a = o + 2 * n.margin,
            u = n.color.light.a ? "<path " + vt(n.color.light, "fill") + ' d="M0 0h' + a + "v" + a + 'H0z"/>' : "",
            s = "<path " + vt(n.color.dark, "stroke") + ' d="' + function (t, e, r) {
                for (var n = "", o = 0, i = !1, a = 0, u = 0; u < t.length; u++) {
                    var s = Math.floor(u % e), f = Math.floor(u / e);
                    s || i || (i = !0), t[u] ? (a++, u > 0 && s > 0 && t[u - 1] || (n += i ? yt("M", s + r, .5 + f + r) : yt("m", o, 0), o = 0, i = !1), s + 1 < e && t[u + 1] || (n += yt("h", a), a = 0)) : o++
                }
                return n
            }(i, o, n.margin) + '"/>', f = 'viewBox="0 0 ' + a + " " + a + '"',
            c = '<svg xmlns="http://www.w3.org/2000/svg" ' + (n.width ? 'width="' + n.width + '" height="' + n.width + '" ' : "") + f + ">" + u + s + "</svg>";
        return "function" == typeof r && r(null, c), c
    };

    function wt(t, e, r, n, i) {
        var a = [].slice.call(arguments, 1), u = a.length, s = "function" == typeof a[u - 1];
        if (!s && !o()) throw new Error("Callback required as last argument");
        if (!s) {
            if (u < 1) throw new Error("Too few arguments provided");
            return 1 === u ? (r = e, e = n = void 0) : 2 !== u || e.getContext || (n = r, r = e, e = void 0), new Promise(function (o, i) {
                try {
                    var a = gt.create(r, n);
                    o(t(a, e, n))
                } catch (t) {
                    i(t)
                }
            })
        }
        if (u < 2) throw new Error("Too few arguments provided");
        2 === u ? (i = r, r = e, e = n = void 0) : 3 === u && (e.getContext && void 0 === i ? (i = n, n = void 0) : (i = n, n = r, r = e, e = void 0));
        try {
            var f = gt.create(r, n);
            i(null, t(f, e, n))
        } catch (t) {
            i(t)
        }
    }

    var Et, At = gt.create, bt = wt.bind(null, pt.render), Bt = wt.bind(null, pt.renderToDataURL),
        Pt = wt.bind(null, function (t, e, r) {
            return mt(t, r)
        }), Ct = (Et = {create: At, toCanvas: bt, toDataURL: Bt, toString: Pt}.toCanvas, function () {
            var t = Array.prototype.slice.call(arguments);
            return new Promise(function (e, r) {
                t.push(function (t, n) {
                    t ? r(t) : e(n)
                }), Et.apply(null, t)
            })
        }), Rt = function (t, e) {
            var r = document.createElement("canvas");
            return Ct(r, t, e).then(function () {
                return r.width
            })
        }, Tt = function (t) {
            return t.length > 36 ? "M" : t.length > 16 ? "Q" : "H"
        }, It = function (t) {
            var e = t.canvas, r = (t.content, t.logo);
            if (r) {
                var n = e.width, o = r.logoSize, i = void 0 === o ? .15 : o, a = r.borderColor, u = r.bgColor,
                    s = void 0 === u ? a || "#ffffff" : u, f = r.borderSize, c = void 0 === f ? .05 : f, l = r.crossOrigin,
                    h = r.borderRadius, g = void 0 === h ? 8 : h, d = r.logoRadius, p = void 0 === d ? 0 : d,
                    v = "string" == typeof r ? r : r.src, y = n * i, m = n * (1 - i) / 2, w = n * (i + c),
                    E = n * (1 - i - c) / 2, A = e.getContext("2d");
                Mt(A)(E, E, w, w, g), A.fillStyle = s, A.fill();
                var b = new Image;
                (l || p) && b.setAttribute("crossOrigin", l || "anonymous"), b.src = v;
                return new Promise(function (t, e) {
                    b.onload = function () {
                        p ? function (t) {
                            var e = document.createElement("canvas");
                            e.width = m + y, e.height = m + y, e.getContext("2d").drawImage(t, m, m, y, y), Mt(A)(m, m, y, y, p), A.fillStyle = A.createPattern(e, "no-repeat"), A.fill()
                        }(b) : function (t) {
                            A.drawImage(t, m, m, y, y)
                        }(b), t()
                    }
                })
            }
        }, Mt = function (t) {
            return function (e, r, n, o, i) {
                var a = Math.min(n, o);
                return i > a / 2 && (i = a / 2), t.beginPath(), t.moveTo(e + i, r), t.arcTo(e + n, r, e + n, r + o, i), t.arcTo(e + n, r + o, e, r + o, i), t.arcTo(e, r + o, e, r, i), t.arcTo(e, r, e + n, r, i), t.closePath(), t
            }
        }, Nt = function (t) {
            return (e = t, r = e.canvas, n = e.content, o = e.width, i = void 0 === o ? 0 : o, a = e.nodeQrCodeOptions, u = void 0 === a ? {} : a, u.errorCorrectionLevel = Tt(n), Rt(n, u).then(function (t) {
                return u.scale = 0 === i ? void 0 : i / t * 4, Ct(r, n, u)
            })).then(function () {
                return t
            }).then(It);
            var e, r, n, o, i, a, u
        }, St = function (t, e) {
            var r = t.src, n = document.createElement("a");
            n.download = e, n.href = r, document.body.appendChild(n), n.click(), document.body.removeChild(n)
        };
    return {
        toCanvas: Nt, toImage: function (t) {
            var e = document.createElement("canvas");
            return t.canvas = e, t.logo && ("string" == typeof t.logo && (t.logo = {src: t.logo}), t.logo.crossOrigin = "Anonymous"), Nt(t).then(function () {
                var r = t.image, n = void 0 === r ? new Image : r, o = t.downloadName, i = void 0 === o ? "qr-code" : o,
                    a = t.download;
                n.src = e.toDataURL(), (!0 === a || "function" == typeof a) && (a = !0 === a ? function (t) {
                    return t()
                } : a)(function () {
                    St(n, i)
                })
            })
        }
    }
});
